<template>
  <div class="yt-dialog-tableTitle">
    <el-checkbox v-model="checkAll" @change="handleCheckAllChange">{{$t('scheduleManager.progressList.allSelect')}}</el-checkbox>
    <div style="margin: 15px 0;"></div>
    <el-checkbox-group v-model="displayBlockName" @change="handleCheckedCitiesChange" class="yt-dialog-tableTitle-checkbox">
      <el-checkbox v-for="block in templateList" :label="block.value" :key="block.value">{{block.label}}</el-checkbox>
    </el-checkbox-group>
    <div class="dialog-tableTitle-footer">
      <el-button class="yt-btn" @click="cancel">{{$t('scheduleManager.progressList.cancel')}}</el-button>
      <el-button class="yt-btn-ys" type="primary" @click="saveDisplayBlock">{{$t('scheduleManager.progressList.sure')}}</el-button>
    </div>
  </div>
</template>

<script>
  import { saveDisplayBlock } from '@/api/pmoReport/projectRevenue';
  export default {
    name: 'YtTableTitle',
    props: {
      blockNameCode: {
        type: String,
        default: ''
      },
      displayBlockNameList: {
        // 列表数据
        type: Array,
        default: () => []
      }
    },
    data() {
      return {
        templateList: [],
        // name:  Data报表, code: 'dataReport'
        templateBlock: {
          dataReport: [
            {
              label: '204結案日',
              value: 'endCaseDate'
            }, {
              label: 'Year',
              value: 'year'
            }, {
              label: '以前年度認列收入',
              value: 'pastYearIncome'
            }, {
              label: '以前年度認列成本',
              value: 'pastYearCost'
            }, {
              label: '專案編號',
              value: 'projectNo'
            }, {
              label: '專案名稱',
              value: 'projectName'
            }, {
              label: '客戶簡稱',
              value: 'customerName'
            }, {
              label: '合約收入',
              value: 'contractIncome'
            }, {
              label: '合約成本',
              value: 'contractCost'
            }, {
              label: '合約收入占比',
              value: 'contractIncomePercentage'
            }, {
              label: '合約毛利',
              value: 'contractGrossProfit'
            }, {
              label: '認列方式',
              value: 'identifyType'
            }, {
              label: '纍計認列收入',
              value: 'sumIdentifyIncome'
            }, {
              label: '纍計認列成本',
              value: 'sumIdentifyCost'
            }, {
              label: '纍計認列直接利潤',
              value: 'sumIdentifyProfit'
            }, {
              label: '合約收入（本年度）',
              value: 'recognizedIncome'
            }, {
              label: '合約成本（本年度）',
              value: 'recognizedCost'
            }, {
              label: '合約毛利（本年度）',
              value: 'contractGrossProfit4Year'
            }, {
              label: '合約收入（明年度）',
              value: 'recognizedIncomeNextYear'
            }, {
              label: '合約成本（明年度）',
              value: 'recognizedCostNextYear'
            }, {
              label: '合約毛利（明年度）',
              value: 'contractGrossProfitNextYear'
            },
            {
              label: '預估應收累計',
              value: 'expectRequestCount'
            },
            {
              label: '應收請款纍計',
              value: 'sumReceivableRequestFunds'
            },
            {
              label: '收款纍計',
              value: 'sumReceivablesFunds'
            },
            {
              label: '預估應收達成%',
              value: 'expectRequestPer'
            },
            {
              label: '預估應付累計',
              value: 'expectPayCount'
            },
            {
              label: '應付請款纍計',
              value: 'sumPayableRequestFunds'
            },
            {
              label: '付款纍計',
              value: 'sumPaymentFunds'
            },
            {
              label: '預估應付達成%',
              value: 'expectPayPer'
            },
            {
              label: '認列結算否',
              value: 'isIdentifySettle'
            }, {
              label: '收付款完成',
              value: 'isPaymentReceived'
            }, {
              label: '專案負責人',
              value: 'dataReport'
            }, {
              label: '負責部門',
              value: 'erpBuNo'
            }, {
              label: 'Account',
              value: 'bu'
            }, {
              label: '預計開始日',
              value: 'expectedStartDate'
            }, {
              label: '預計完工日',
              value: 'estimatedCompletionDate'
            }, {
              label: '驗收日期',
              value: 'acceptanceDate'
            }, {
              label: '類型',
              value: 'type'
            }, {
              label: '累計完工收入',
              value: 'completionIncomeCount'
            }, {
              label: '累計完工成本(含能專)',
              value: 'completionCostCount'
            }, {
              label: '能專成本',
              value: 'projectAbilityCost'
            }, {
              label: '能專成本(以前年度)',
              value: 'projectAbilityCostPastYear'
            }, {
              label: '完工收入(本年度)',
              value: 'completionIncomeCountSubtractPast'
            }, {
              label: '完工成本(本年度)',
              value: 'completionCostCountSubtractPast'
            }, {
              label: '完工毛利(本年度)',
              value: 'completionProfitSubtractPast'
            },
            {
              label: '完工%(本年度)',
              value: 'completionPercentage4Year'
            },
            {
              label: '完工%',
              value: 'estimatedCompletionPercentage'
            }, {
              label: '成案否',
              value: 'isFinish'
            }, {
              label: '纍計人員工時',
              value: 'workingHoursCount'
            }, {
              label: '專案人力成本',
              value: 'projectLaborCost'
            }, {
              label: '管理人力成本',
              value: 'manageLaborCost'
            }
          ],
          buOne: [
            {
              label: 'Category',
              value: 'bg'
            },
            {
              label: 'Account',
              value: 'bu'
            },
            {
              label: 'Year',
              value: 'year'
            },
            {
              label: '合約收入（本年度）',
              value: 'recognizedIncome'
            },
            {
              label: '合約成本（本年度）',
              value: 'recognizedCost'
            },
            {
              label: '合約毛利（本年度）',
              value: 'contractGrossProfit4Year'
            },
            {
              label: '合約毛利（本年度）%',
              value: 'contractGrossProfit4YearPercentage'
            },
            {
              label: '合約收入（以后年度）',
              value: 'contractIncomeAfterYear'
            },
            {
              label: '合約成本（以后年度）',
              value: 'contractCostAfterYear'
            },
            {
              label: '合約毛利（以后年度）',
              value: 'contractGrossProfitAfterYear'
            },
            {
              label: '合約毛利（以后年度）%',
              value: 'contractGrossProfitAfterYearPercentage'
            },
            {
              label: '合約收入（以前年度）',
              value: 'pastYearIncome'
            },
            {
              label: '合約成本（以前年度）',
              value: 'pastYearCost'
            },
            {
              label: '合約毛利(以前年度)',
              value: 'contractGrossProfitPastYear'
            },
            {
              label: '合約毛利(以前年度)%',
              value: 'contractGrossProfitPastYearPercentage'
            },
            {
              label: '合約收入',
              value: 'contractIncome'
            },
            {
              label: '合約成本',
              value: 'contractCost'
            },
            {
              label: '合約毛利',
              value: 'contractGrossProfit'
            },
            {
              label: '合約毛利%',
              value: 'contractGrossProfitPercentage'
            }
          ],
          buTwo: [
            {
              label: 'Category',
              value: 'bg'
            },
            {
              label: 'Account',
              value: 'bu'
            },
            {
              label: 'Year',
              value: 'year'
            },
            {
              label: '合約收入（本年度）',
              value: 'recognizedIncome'
            },
            {
              label: '完工收入（本年度）',
              value: 'completionIncome4Year'
            },
            {
              label: '完工成本（本年度）',
              value: 'completionCost4Year'
            },
            {
              label: '完工毛利（本年度）',
              value: 'completionProfit4Year'
            },
            {
              label: '完工占比（本年度）%',
              value: 'completionPercentage4Year'
            },
            {
              label: '完工收入(纍計)',
              value: 'completionIncomeCount'
            },
            {
              label: '完工成本(纍計)',
              value: 'completionCostCount'
            },
            {
              label: '財務纍計認列收入',
              value: 'sumIdentifyIncome'
            },
            {
              label: '財務纍計認列成本',
              value: 'sumIdentifyCost'
            },
            {
              label: '已收金額',
              value: 'sumReceivablesFunds'
            },
            {
              label: '已付金額',
              value: 'sumPaymentFunds'
            },
            {
              label: '未收金額',
              value: 'notReceiveAmount'
            },
            {
              label: '未付金額',
              value: 'notPaymentAmount'
            },
            {
              label: '已開發票未收款',
              value: 'sumReceivableRequestFunds'
            },
            {
              label: '已收發票未付款',
              value: 'sumPayableRequestFunds'
            }
          ],
          buThree: [
            {
              label: 'Category',
              value: 'bg'
            },
            {
              label: 'Account',
              value: 'bu'
            },
            {
              label: '完工收入（本年度）',
              value: 'completionIncome4Year'
            },
            {
              label: '完工成本（本年度）',
              value: 'completionCost4Year'
            },
            {
              label: '專案人力成本',
              value: 'projectLaborCost'
            },
            {
              label: '管理人力成本',
              value: 'manageLaborCost'
            },
            {
              label: '業務費用',
              value: 'businessCost'
            },
            {
              label: '完工毛利',
              value: 'completionProfit4Year'
            },
            {
              label: '完工毛利占比',
              value: 'completionProfitPercentage4Year'
            },
            // {
            //   label: '成本小计',
            //   value: 'costTotal'
            // },
            // {
            //   label: '成本占比',
            //   value: 'costTotalPercentage'
            // },
            {
              label: '管理成本',
              value: 'manageCost'
            },
            {
              label: '管理成本攤銷',
              value: 'manageCostAmortization'
            },
            {
              label: '折舊攤銷',
              value: 'amortization'
            },
            {
              label: 'HQ攤銷',
              value: 'hQAmortization'
            },
            {
              label: '營業毛利',
              value: 'operatingProfit'
            },
            {
              label: '營業毛利率 %',
              value: 'operatingProfitPercentage'
            }
          ],
          projectOne: [
            {
              label: '專編',
              value: 'projectNo'
            },
            {
              label: '專案名稱',
              value: 'projectName'
            },
            {
              label: '成案否',
              value: 'isFinish'
            },
            {
              label: '合約收入（本年度）',
              value: 'recognizedIncome'
            },
            {
              label: '合約成本（本年度）',
              value: 'recognizedCost'
            },
            {
              label: '合約毛利（本年度）',
              value: 'contractGrossProfit4Year'
            },
            {
              label: '合約毛利（本年度）%',
              value: 'contractGrossProfit4YearPercentage'
            },
            {
              label: '合約收入（以后年度）',
              value: 'contractIncomeAfterYear'
            },
            {
              label: '合約成本（以后年度）',
              value: 'contractCostAfterYear'
            },
            {
              label: '合約毛利（以后年度）',
              value: 'contractGrossProfitAfterYear'
            },
            {
              label: '合約毛利（以后年度）%',
              value: 'contractGrossProfitAfterYearPercentage'
            },
            {
              label: '合約收入（以前年度）',
              value: 'pastYearIncome'
            },
            {
              label: '合約成本（以前年度）',
              value: 'pastYearCost'
            },
            {
              label: '合約毛利(以前年度)',
              value: 'contractGrossProfitPastYear'
            },
            {
              label: '合約毛利(以前年度)%',
              value: 'contractGrossProfitPastYearPercentage'
            },
            {
              label: '合約收入',
              value: 'contractIncome'
            },
            {
              label: '合約成本',
              value: 'contractCost'
            },
            {
              label: '合約毛利',
              value: 'contractGrossProfit'
            },
            {
              label: '合約毛利%',
              value: 'contractGrossProfitPercentage'
            },
            {
              label: '完工收入（本年度）',
              value: 'completionIncome4Year'
            },
            {
              label: '完工成本（本年度）',
              value: 'completionCost4Year'
            },
            {
              label: '完工毛利（本年度）',
              value: 'completionProfit4Year'
            },
            {
              label: '完工占比（本年度）%',
              value: 'completionPercentage4Year'
            },
            {
              label: '完工收入(纍計)',
              value: 'completionIncomeCount'
            },
            {
              label: '完工成本(纍計)',
              value: 'completionCostCount'
            },
            {
              label: '財務纍計認列收入',
              value: 'sumIdentifyIncome'
            },
            {
              label: '財務纍計認列成本',
              value: 'sumIdentifyCost'
            },
            {
              label: '已收金額',
              value: 'sumReceivablesFunds'
            },
            {
              label: '已付金額',
              value: 'sumPaymentFunds'
            },
            {
              label: '未收金額',
              value: 'notReceiveAmount'
            },
            {
              label: '未付金額',
              value: 'notPaymentAmount'
            },
            {
              label: '已開發票未收款',
              value: 'sumReceivableRequestFunds'
            },
            {
              label: '已收發票未付款',
              value: 'sumPayableRequestFunds'
            }
          ],
          /* projectTwo: [
            {
              label: '專編',
              value: 'projectNo'
            },
            {
              label: '專案名稱',
              value: 'projectName'
            },
            {
              label: '成案否',
              value: 'isFinish'
            },
            {
              label: '合約收入（本年度）',
              value: 'recognizedIncome'
            },
            {
              label: '完工收入（本年度）',
              value: 'completionIncome4Year'
            },
            {
              label: '完工成本（本年度）',
              value: 'completionCost4Year'
            },
            {
              label: '完工毛利（本年度）',
              value: 'completionProfit4Year'
            },
            {
              label: '完工占比（本年度）%',
              value: 'completionPercentage4Year'
            },
            {
              label: '完工收入(纍計)',
              value: 'completionIncomeCount'
            },
            {
              label: '完工成本(纍計)',
              value: 'completionCostCount'
            },
            {
              label: '財務纍計認列收入',
              value: 'sumIdentifyIncome'
            },
            {
              label: '財務纍計認列成本',
              value: 'sumIdentifyCost'
            },
            {
              label: '已收金額',
              value: 'sumReceivablesFunds'
            },
            {
              label: '已付金額',
              value: 'sumPaymentFunds'
            },
            {
              label: '未收金額',
              value: 'notReceiveAmount'
            },
            {
              label: '未付金額',
              value: 'notPaymentAmount'
            },
            {
              label: '已開發票未收款',
              value: 'sumReceivableRequestFunds'
            },
            {
              label: '已收發票未付款',
              value: 'sumPayableRequestFunds'
            }
          ],
          projectThree: [
            {
              label: '專編',
              value: 'projectNo'
            },
            {
              label: '專案名稱',
              value: 'projectName'
            },
            {
              label: '成案否',
              value: 'isFinish'
            },
            {
              label: '合約收入（本年度）',
              value: 'recognizedIncome'
            },
            {
              label: '合約成本（本年度）',
              value: 'recognizedCost'
            },
            {
              label: '合約毛利（本年度）',
              value: 'contractGrossProfit4Year'
            },
            {
              label: '合約毛利（本年度）%',
              value: 'contractGrossProfit4YearPercentage'
            },
            {
              label: '合約收入（以后年度）',
              value: 'contractIncomeAfterYear'
            },
            {
              label: '合約成本（以后年度）',
              value: 'contractCostAfterYear'
            },
            {
              label: '合約毛利（以后年度）',
              value: 'contractGrossProfitAfterYear'
            },
            {
              label: '合約毛利（以后年度）%',
              value: 'contractGrossProfitAfterYearPercentage'
            },
            {
              label: '合約收入（以前年度）',
              value: 'pastYearIncome'
            },
            {
              label: '合約成本（以前年度）',
              value: 'pastYearCost'
            },
            {
              label: '合約毛利(以前年度)',
              value: 'contractGrossProfitPastYear'
            },
            {
              label: '合約毛利(以前年度)%',
              value: 'contractGrossProfitPastYearPercentage'
            },
            {
              label: '合約收入',
              value: 'contractIncome'
            },
            {
              label: '合約成本',
              value: 'contractCost'
            },
            {
              label: '合約毛利',
              value: 'contractGrossProfit'
            },
            {
              label: '合約毛利%',
              value: 'contractGrossProfitPercentage'
            }
          ],
          projectFour: [
            {
              label: '專編',
              value: 'projectNo'
            },
            {
              label: '專案名稱',
              value: 'projectName'
            },
            {
              label: '成案否',
              value: 'isFinish'
            },
            {
              label: '合約收入（本年度）',
              value: 'recognizedIncome'
            },
            {
              label: '完工收入（本年度）',
              value: 'completionIncome4Year'
            },
            {
              label: '完工成本（本年度）',
              value: 'completionCost4Year'
            },
            {
              label: '完工毛利（本年度）',
              value: 'completionProfit4Year'
            },
            {
              label: '完工占比（本年度）%',
              value: 'completionPercentage4Year'
            },
            {
              label: '完工收入(纍計)',
              value: 'completionIncomeCount'
            },
            {
              label: '完工成本(纍計)',
              value: 'completionCostCount'
            },
            {
              label: '財務纍計認列收入',
              value: 'sumIdentifyIncome'
            },
            {
              label: '財務纍計認列成本',
              value: 'sumIdentifyCost'
            },
            {
              label: '已收金額',
              value: 'sumReceivablesFunds'
            },
            {
              label: '已付金額',
              value: 'sumPaymentFunds'
            },
            {
              label: '未收金額',
              value: 'notReceiveAmount'
            },
            {
              label: '未付金額',
              value: 'notPaymentAmount'
            },
            {
              label: '已開發票未收款',
              value: 'sumReceivableRequestFunds'
            },
            {
              label: '已收發票未付款',
              value: 'sumPayableRequestFunds'
            }
          ], */
          buPieChart: [
            {
              label: this.$t('buPieChart.buChart.completedCost'),
              value: 'completedCost'
            },
            {
              label: this.$t('buPieChart.buChart.sumProjectHumanCost'),
              value: 'sumProjectHumanCost'
            },
            {
              label: this.$t('buPieChart.buChart.sumManageHumanCost'),
              value: 'sumManageHumanCost'
            },
            {
              label: this.$t('buPieChart.buChart.managementCost'),
              value: 'managementCost'
            },
            {
              label: this.$t('buPieChart.buChart.businessExpenses'),
              value: 'businessExpenses'
            },
            {
              label: this.$t('buPieChart.buChart.amortization'),
              value: 'amortization'
            },
            {
              label: this.$t('buPieChart.buChart.hqAmortization'),
              value: 'hqAmortization'
            },
            {
              label: this.$t('buPieChart.buChart.manageCostAmortization'),
              value: 'manageCostAmortization'
            }
          ],
          completionPayment: [
            {
              label: 'Year',
              value: 'year'
            },
            {
              label: this.$t('buPieChart.completionPayment.recognizedIncome'),
              value: 'recognizedIncome'
            },
            {
              label: this.$t('buPieChart.completionPayment.recognizedCost'),
              value: 'recognizedCost'
            },
            {
              label: this.$t('buPieChart.completionPayment.completedIncome'),
              value: 'completedIncome'
            },
            {
              label: this.$t('buPieChart.completionPayment.completedCost'),
              value: 'completedCost'
            },
            {
              label: this.$t('buPieChart.completionPayment.receivable'),
              value: 'receivable'
            },
            {
              label: this.$t('buPieChart.completionPayment.invoiced'),
              value: 'invoiced'
            },
            {
              label: this.$t('buPieChart.completionPayment.uninvoiced'),
              value: 'uninvoiced'
            },
            {
              label: this.$t('buPieChart.completionPayment.accountPaid'),
              value: 'accountPaid'
            },
            {
              label: this.$t('buPieChart.completionPayment.unaccountPaid'),
              value: 'unaccountPaid'
            }
          ],
          monthlyWorks: [
            {
              label: 'EMS',
              value: 'monthName'
            },
            {
              label: this.$t('buPieChart.monthlyWorks.recognizedIncome'),
              value: 'recognizedIncome'
            },
            {
              label: this.$t('buPieChart.monthlyWorks.completedIncome'),
              value: 'completedIncome'
            },
            {
              label: this.$t('buPieChart.monthlyWorks.completedCost'),
              value: 'completedCost'
            },
            {
              label: this.$t('buPieChart.monthlyWorks.completedGrossProfit'),
              value: 'completedGrossProfit'
            },
            {
              label: this.$t('buPieChart.monthlyWorks.manageAmortizationCost'),
              value: 'manageAmortizationCost'
            },
            {
              label: this.$t('buPieChart.monthlyWorks.grossBusinessProfit'),
              value: 'grossBusinessProfit'
            },
            {
              label: this.$t('buPieChart.monthlyWorks.completedManageAmortizationCost'),
              value: 'completedManageAmortizationCost'
            },
            {
              label: this.$t('buPieChart.monthlyWorks.completedMonthIncome'),
              value: 'completedMonthIncome'
            },
            {
              label: this.$t('buPieChart.monthlyWorks.completedManageAmortization'),
              value: 'completedManageAmortization'
            }
          ],
          maintenance: [
            {
              label: this.$t('specialApplication.maintenance.country'),
              value: 'countryName'
            },
            {
              label: 'Category',
              value: 'BG'
            },
            {
              label: 'Account',
              value: 'BU'
            },
            {
              label: '財務模式',
              value: 'clientTypeName'
            },
            {
              label: 'Territory',
              value: 'territory'
            },
            {
              label: 'Client',
              value: 'clientName'
            },
            {
              label: 'BD No.',
              value: 'bdValue'
            },
            {
              label: 'BD Name',
              value: 'bdName'
            },
            {
              label: 'Contact window',
              value: 'contactWindowF'
            },
            {
              label: 'Decision maker',
              value: 'decisionMakerF'
            },
            {
              label: 'Sales',
              value: 'sales'
            },
            {
              label: 'Presales',
              value: 'presales'
            },
            {
              label: 'PM',
              value: 'pm'
            },
            {
              label: 'Start Date',
              value: 'startDate'
            },
            {
              label: 'End Date',
              value: 'endDate'
            },
             {
              label: '實際報價日',
              value: 'proposalDate'
            },
            {
              label: 'Target Quarter',
              value: 'targetQuarter'
            },
            {
              label: 'Award Date',
              value: 'awardDate'
            },
            {
              label: 'Agenda1',
              value: 'agenda1'
            },
            {
              label: 'Agenda2',
              value: 'agenda2'
            },
            {
              label: 'Agenda3',
              value: 'agenda3'
            },
            {
              label: 'Agenda4',
              value: 'agenda4'
            },
            {
              label: 'Agenda5',
              value: 'agenda5'
            },
            {
              label: 'Agenda6',
              value: 'agenda6'
            },
            {
              label: this.$t('specialApplication.maintenance.bidBeforeMeetingRemark'),
              value: 'bidBeforeMeetingRemark'
            },
            {
              label: '預計簽約日',
              value: 'targetMonth'
            },
            {
              label: '預計報價日',
              value: 'forecastMonth'
            },
            {
              label: 'Estimated Budget',
              value: 'estimatedBudget'
            },
            {
              label: 'Estimated cost',
              value: 'estimatedCost'
            },
            {
              label: 'Estimated Revenue(this year)',
              value: 'estimatedRevenueThis'
            },
            {
              label: 'Estimated Cost(this year)',
              value: 'estimatedCostThis'
            },
            {
              label: 'Status',
              value: 'status'
            },
            {
              label: 'Win Odds %',
              value: 'winOddsName'
            },
            {
              label: 'Tracking Time',
              value: 'traceMonth'
            },
            {
              label: '進度說明(Sales&Presales)',
              value: 'actionsSales'
            },
            {
              label: '進度說明(高階主管)',
              value: 'actionsPresales'
            },
            {
              label: this.$t('specialApplication.maintenance.isFinishValue'),
              value: 'isFinishValue'
            },
            {
              label: this.$t('specialApplication.maintenance.projectNo'),
              value: 'projectNo'
            },
            {
              label: this.$t('specialApplication.maintenance.bidBeforeMeetingDate'),
              value: 'bidBeforeMeetingDate'
            },
            {
              label: this.$t('specialApplication.maintenance.innerStartMeetingDate') + '(Award70%)',
              value: 'innerStartMeetingDate'
            },
            {
              label: this.$t('specialApplication.maintenance.outerStartMeetingDate') + '(Award70%)',
              value: 'outerStartMeetingDate'
            },
             {
              label: 'Task',
              value: 'task'
            },
              {
              label: 'TargetDate',
              value: 'targetDate'
            },
            {
              label: '董事會列管收入',
              value: 'directorIncome'
            },
             {
              label: '董事會列管成本',
              value: 'directorCost'
            },
              {
              label: '董事會列管年度',
              value: 'directorDate'
            }
          ],
          businessMeeting: [
            {
              label: this.$t('specialApplication.businessMeeting.country'),
              value: 'countryName'
            },
            {
              label: 'Category',
              value: 'BG'
            },
            {
              label: 'Account',
              value: 'BU'
            },
            {
              label: 'Client',
              value: 'clientName'
            },
            {
              label: 'BD No.',
              value: 'bdValue'
            },
            {
              label: 'BD Name',
              value: 'bdName'
            },
            {
              label: 'Sales',
              value: 'sales'
            },
            {
              label: 'Presales',
              value: 'presales'
            },
            {
              label: 'PM',
              value: 'pm'
            },
            {
              label: 'Start Date',
              value: 'startDate'
            },
            {
              label: 'End Date',
              value: 'endDate'
            },
            {
              label: 'Target Quarter',
              value: 'targetQuarter'
            },
            {
              label: 'Award Date',
              value: 'awardDate'
            },
            // {
            //   label: 'Agenda1',
            //   value: 'agenda1'
            // },
            // {
            //   label: 'Agenda2',
            //   value: 'agenda2'
            // },
            // {
            //   label: 'Agenda3',
            //   value: 'agenda3'
            // },
            // {
            //   label: 'Agenda4',
            //   value: 'agenda4'
            // },
            // {
            //   label: 'Agenda5',
            //   value: 'agenda5'
            // },
            // {
            //   label: 'Agenda6',
            //   value: 'agenda6'
            // },
            {
              label: this.$t('specialApplication.businessMeeting.bidBeforeMeetingRemark'),
              value: 'bidBeforeMeetingRemark'
            },
            {
              label: 'Target Month',
              value: 'targetMonth'
            },
            {
              label: 'Estimated Budget',
              value: 'estimatedBudget'
            },
            {
              label: 'Estimated cost',
              value: 'estimatedCost'
            },
            {
              label: 'Status',
              value: 'status'
            },
            {
              label: 'Win Odds %',
              value: 'winOddsName'
            },
            {
              label: 'Tracking Time',
              value: 'traceMonth'
            },
            {
              label: 'Action-Sales',
              value: 'actionsSales'
            },
            {
              label: 'Action-Presales',
              value: 'actionsPresales'
            },
            {
              label: this.$t('specialApplication.businessMeeting.isFinishValue'),
              value: 'isFinishValue'
            },
            {
              label: this.$t('specialApplication.businessMeeting.projectNo'),
              value: 'projectNo'
            },
            {
              label: this.$t('specialApplication.businessMeeting.bidBeforeMeetingDate'),
              value: 'bidBeforeMeetingDate'
            },
            {
              label: this.$t('specialApplication.businessMeeting.innerStartMeetingDate') + '(Award70%)',
              value: 'innerStartMeetingDate'
            },
            {
              label: this.$t('specialApplication.businessMeeting.outerStartMeetingDate') + '(Award70%)',
              value: 'outerStartMeetingDate'
            }
          ],
          projectMeeting: [
            {
              label: 'Category',
              value: 'bg'
            },
            {
              label: 'Account',
              value: 'bu'
            },
            {
              label: this.$t('specialApplication.projectMeeting.projectNo'),
              value: 'projectCode'
            },
            {
              label: this.$t('specialApplication.projectMeeting.projectName'),
              value: 'projectName'
            },
            {
              label: this.$t('specialApplication.projectMeeting.customerName'),
              value: 'customerName'
            },
            {
              label: this.$t('specialApplication.projectMeeting.systemNo'),
              value: 'systemNo'
            },
            {
              label: '專案業務',
              value: 'projectBusinessName'
            },
            {
              label: '專案工程師',
              value: 'projectEngineer'
            },
            {
              label: 'Year',
              value: 'projectYear'
            },
            {
              label: '合約收入',
              value: 'contractIncome'
            },
            {
              label: 'PO核准日',
              value: 'poApprovalDate'
            },
            {
              label: '施工前BP日',
              value: 'beforeBpDate'
            },
            {
              label: '預計完工日',
              value: 'expectedFinishDate'
            },
            {
              label: '實際完工日',
              value: 'realityFinishDate'
            },
            {
              label: '完工%',
              value: 'estimatedCompletionPercentage'
            },
            {
              label: '專案進度會議(本期)',
              value: 'projectMeetingScheduleThis'
            },
            {
              label: '專案進度會議(次期)',
              value: 'projectMeetingScheduleNext'
            },
            {
              label: '結案會議',
              value: 'closingMeeting'
            },
            {
              label: '專案進度會議備註',
              value: 'projectMeetingScheduleRemarks'
            },
            {
              label: '結案會議備註',
              value: 'closingMeetingRemarks'
            }
          ]
        },
        isIndeterminate: true,
        checkAll: false,
        selectedValue: null,
        displayBlockName: []
      };
    },
    methods: {
      // 全选
      handleCheckAllChange(val) {
        const list = []
        if (val) {
          this.templateList.forEach(key => {
            list.push(key.value)
          })
        }
        this.displayBlockName = val ? list : [];
        this.isIndeterminate = false;
      },
      handleCheckedCitiesChange(value) {
        const checkedCount = value.length;
        // 全选
        this.checkAll = checkedCount === this.templateBlock.length;
        this.isIndeterminate = checkedCount > 0 && checkedCount < this.templateBlock.length;
      },
      cancel() {
        this.$emit('cancel')
      },
      saveDisplayBlock() {
        const data = {
          codeList: this.displayBlockName,
          tableName: this.blockNameCode,
          userId: this.$store.getters.info.id
        }
        saveDisplayBlock(data).then(res => {
          if (res.status === 200) {
            this.$message.success('保存成功')
            this.$emit('cancel', true)
          }
        })
      }
    },
    watch: {
      blockNameCode(val) {
        console.log(this.blockNameCode, 'blockNameCode');
        if (val) {
          this.templateList = this.templateBlock[val]
        }
      },
      displayBlockNameList(val) {
        this.displayBlockName = val
        this.checkAll = this.templateList.length === this.displayBlockName.length;
        console.log(this.templateList.length)
        console.log(this.displayBlockName.length)
      }
    },
    mounted() {
      this.displayBlockName = this.displayBlockNameList
      if (this.blockNameCode) {
        this.templateList = this.templateBlock[this.blockNameCode]
      }
      this.checkAll = this.templateList.length === this.displayBlockName.length;
      console.log(this.templateList.length)
      console.log(this.displayBlockName.length)
    }
  };
</script>

<style scoped lang="scss">
.dialog-tableTitle-footer{
    text-align: right;
    margin-top: 30px;
}
.yt-dialog-tableTitle-checkbox{
  .el-checkbox{
    min-width: 300px;
  }
  .el-checkbox+.el-checkbox {
    margin-left: 0px;
  }
}
</style>
